#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back

const int N=1e6+5,inf=1e9;
int n,idx=0,rmn=inf,lmx=0,tp=0,len=inf,ans=inf,rmnl,lmxr,V=0;
map<pii,int> mp;
struct Nod{
  int x,y;
  Nod(int a=0,int b=0){x=a,y=b;}
  bool operator <(const Nod &a) const{return x==a.x?y<a.y:x<a.x;}
};
struct Line{
  int l,r,s,t;
}L[N];
vector<pii> G[N<<2];

#define mid ((l+r)>>1)
#define lc p<<1
#define rc p<<1|1
#define lson l,mid,lc
#define rson mid+1,r,rc

struct Undo{
  int op,x,v;
}st[N*20];

namespace BIT{
  int trl[N],trr[N];
  
  int lowbit(int i){return i&(-i);}
  void init(){for(int i=0;i<=V;i++) trl[i]=-inf,trr[i]=inf;}
  
  void updl(int r,int l){
    for(int i=r;i<=V;i+=lowbit(i))
      if(l>trl[i]) st[++tp]={0,i,trl[i]},trl[i]=l;
  }
  
  void updr(int l,int r){
    for(int i=l;i>=1;i-=lowbit(i))
      if(r<trr[i]) st[++tp]={1,i,trr[i]},trr[i]=r;
  }
  
  int qryl(int x){
    int res=-inf;
    for(int i=x-1;i>=1;i-=lowbit(i)) res=max(res,trl[i]);
    return res;
  }
  
  int qryr(int x){
    int res=inf;
    for(int i=x+1;i<=V;i+=lowbit(i)) res=min(res,trr[i]);
    return res;
  }
  
  void Ins(int l,int r){
    int tmp=min({inf,r-qryl(l)+1,qryr(r)-l+1});
    
//    cerr<<"Ins : "<<l<<' '<<r<<" -> "<<tmp<<" -> "<<qryl(l)<<endl;
    
    if(tmp<ans) st[++tp]={2,0,ans},ans=tmp;
    updl(r,l),updr(l,r);
    if(r-l+1<len) st[++tp]={3,0,len},len=r-l+1;
    if(r<rmn||(r==rmn&&l>rmnl)) st[++tp]={4,rmn,rmnl},rmn=r,rmnl=l;
    if(l>lmx||(l==lmx&&r<lmxr)) st[++tp]={5,lmx,lmxr},lmx=l,lmxr=r;
  }
}

void undo(){
  int op=st[tp].op,x=st[tp].x,v=st[tp].v;
  if(op==0) BIT::trl[x]=v;
  else if(op==1) BIT::trr[x]=v;
  else if(op==2) ans=v;
  else if(op==3) len=v;
  else if(op==4) rmn=x,rmnl=v;
  else lmx=x,lmxr=v;
  --tp;
}

int calc(){
  if(rmn<lmx) return ans;
  if(len<rmn-lmx+1) return len;
  if(len>rmn-lmx+1) return lmxr-rmnl+1;
  return min(len,lmxr-rmnl+1);
}

void Upd(int x,int y,pii v,int l=1,int r=n,int p=1){
  if(x<=l&&y>=r) return G[p].pb(v),void();
  if(x<=mid) Upd(x,y,v,lson);
  if(y>mid) Upd(x,y,v,rson);
}

void solve(int l=1,int r=n,int p=1){
  int cur=tp;
  for(auto i:G[p]) BIT::Ins(i.fi,i.se);

  if(l==r) cout<<calc()<<'\n';
  else solve(lson),solve(rson);

  while(tp>cur) undo();
}

int main(){
  freopen("stone.in","r",stdin);
  freopen("stone.out","w",stdout);
  
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>n;
  for(int i=1;i<=n;i++){
    char op;int l,r;
    cin>>op>>l>>r;--r,V=max(V,r);
    if(!mp.count({l,r})||!mp[{l,r}]) mp[{l,r}]=++idx,L[idx]={l,r,i,n};
    if(op=='R') L[mp[{l,r}]].t=i-1,mp[{l,r}]=0;
  }
  BIT::init();
  for(int i=1;i<=idx;i++) Upd(L[i].s,L[i].t,{L[i].l,L[i].r});//,cerr<<"L( "<<i<<" ) = "<<L[i].l<<' '<<L[i].r<<' '<<L[i].s<<' '<<L[i].t<<endl;
  solve();
  return 0;
}
